package redis

import (
	"context"
	"everyone/C/rpc_C/appconfig"
	"fmt"
	"github.com/go-redis/redis/v8"
)

var Client *redis.Client

func RedisInit() {
	Client = redis.NewClient(&redis.Options{
		Addr:     appconfig.ViperData.Redis.Addr,
		Password: appconfig.ViperData.Redis.Password, // no password set
		DB:       appconfig.ViperData.Redis.DB,       // use default DB
	})

	pong, err := Client.Ping(context.Background()).Result()
	fmt.Println(pong)
	if err != nil {
		panic(err)
	} else {
		fmt.Println("redis链接成功")
	}
}
